#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#                              Control files for the validation                           ++
#                         Lei Zhu (leizhu@fas.harvard.edu), 11/08/2019                    ++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Set flight campigans to include
#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Campigans_used          <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#                              Folders in the main dir                                    ++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#///////////////////////////////////////////////////////////////////////////////////////////

#---> RData folder
RData_folder            <- "RData/"

#---> Output fig files
FigFolder               <- "Figs/"

#---> Filename to save the validation results 
logFile                 <- "Results.txt"

#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#                               Set spatial resolution                                    ++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#///////////////////////////////////////////////////////////////////////////////////////////

#---> Used for spatial regridding and final plots
Res                     <- 0.5

#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#                                Satellite related setups                                 ++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#///////////////////////////////////////////////////////////////////////////////////////////

#---> Read satellite L2 files, 1 for yes, 0 for no
# By turning this on, the script will read L2 files and save a RData file
Read_HCHO_L2            <- 0

#---> Satellite L2 files
L2_data_folder          <- "L2/"

#---> Define field name (FN) to be read from a L2 hdf file
Time_FN                 <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Geolocation Fields/TimeUTC"
Lat_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Geolocation Fields/Latitude"
Lon_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Geolocation Fields/Longitude"
SZA_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Geolocation Fields/SolarZenithAngle"
VZA_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Geolocation Fields/ViewingZenithAngle"
CloudFra_FN             <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/AMFCloudFraction"
MainFlag_FN             <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/MainDataQualityFlag"
GasProfile_FN           <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/GasProfile"
ScatterW_FN             <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/ScatteringWeights"
PreLevel_FN             <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/ClimatologyLevels"
VCD_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/ReferenceSectorCorrectedVerticalColumn"
SCD_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/ColumnAmount"
AMF_FN                  <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/AirMassFactor"
AMFg_FN                 <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/AirMassFactorGeometric"
Albedo_FN               <- "/HDFEOS/SWATHS/OMI Total Column Amount HCHO/Data Fields/Albedo"

#---> MAX valid pixels during the whole campigan
MAX_pixels              <- 1.5e6

#---> MAX pixels falling into a grid cell in a day
MAX_pixels_day          <- 20

#---> Min pixels needed for a valide average
Pixel_limit             <- 0

#---> Cloud fraction limits for a valid pixel
VCD_limit               <- c( -0.5e15, 1.0e17 )

#---> Value limits for a valid pixel
CF_limit                <- c(  0.0   , 0.3    )

#---> SZA limits for a valid pixel
SZA_limit               <- c(  0.0   , 60.0   )

#---> Levels of GEOS-Chem output, no need to change
NLEVS_GC                <- 47

#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#                        Options for plots, 1 for yes, 0 for no                           ++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#///////////////////////////////////////////////////////////////////////////////////////////

#---> Flight tracks colored by HCHO
Plot_Flight_tracks      <- 1

#---> Observed and modeled HCHO vertical profiles 
Plot_HCHO_profile       <- 1

#---> AMF components
# Mean column over the domain, averaged during the campigan period, same for followings
Plot_AMF_components     <- 1

#---> Satellite columns
Plot_Satellite_column   <- 1

#---> Corrected GEOS-Chem columns
Plot_Corr_GC_column     <- 1

#---> Updated columns (computed using GC shape factors)
Plot_Updated_column     <- 1

#---> Albedo
Plot_Albedo             <- 1

#///////////////////////////////////////////////////////////////////////////////////////////
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#                            Set plot-related variables                                   ++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#///////////////////////////////////////////////////////////////////////////////////////////

#---> Plot size
#                            1     2     3     4     5     6     7     8     9     10    11    12
plot_height_all         <- c(6.00, 6.00, 6.00, 6.00, 6.00, 6.00, 6.00, 6.00, 6.00, 6.00, 8.00, 8.00)
plot_width_all          <- c(4.30, 9.60, 6.65, 5.40, 4.07, 8.00, 9.10, 3.45, 5.90, 6.30, 3.00, 3.00)

#---> Flight tracks
Flight_min              <- 0
Flight_max              <- 5

#---> Vertical profiles of HCHO
Profile_xmax 		        <- 6
Profile_ymax            <- 12

#---> Satellite columns
Satellite_min           <- 0
Satellite_max           <- c(40,   30,   30,   30,   32,   35,   25,   30,   35,   20,   10,   10)

#---> New GC columns
NewSatellite_min        <- 0
NewSatellite_max        <- c(45,   30,   30,   30,   32,   35,   25,   30,   35,    20,   10,   10)

#---> Corrected GC columns
CorrectedGC_min         <- 0
CorrectedGC_max         <- c(10,   30,   30,   30,   12,   12,    5,   12,   25,    20,   10,   10)
#                            1     2     3     4     5     6      7     8     9     10    11    12

#---> Albedo
Albedo_min              <- 0
Albedo_max              <- 0.3
